﻿using Cinser.DBUtility.DAL;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;

namespace CExcelOp.BLL
{

    public class BLLOracleCommon : IDALFactory
    {
        //string constr = @"Provider=OraOLEDB.Oracle;Data Source=192.168.1.24/NMDK;User Id=nmdk;Password=nmdk;";
        OracleDALCommon dal;
        public BLLOracleCommon(string dbConnection)
        {
            dal = new OracleDALCommon(dbConnection);
        }

        public bool ExecuteNonQuery(string sql)
        {
            return dal.ExecuteNonQuery(sql);
        }
        public bool Open()
        {
            return dal.Open();
        }
        public void Close()
        {
            if (dal != null)
                dal.Close();
        }
        public bool IsExistTable(string tableName)
        {
            return dal.IsExistTable(tableName);
        }
        /// <summary>
        /// 返回是否存在某一列等于一个值
        /// </summary>
        /// <param name="tableName">表名</param>
        /// <param name="columnName">列名</param>
        /// <param name="columnValue">值</param>
        /// <returns></returns>
        public bool IsExist(string tableName, string columnName, string columnValue)
        {
            return dal.IsExist(tableName, columnName, columnValue);
        }

        public bool IsExist(string tableName, string columnName, int columnValue)
        {
            return dal.IsExist(tableName, columnName, columnValue);
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="tableName">表名</param>
        /// <param name="columnNames">列名</param>
        /// <param name="columnValues">值</param>
        /// <returns></returns>
        public bool IsExist(string tableName, string[] columnNames, string[] columnValues)
        {
            return dal.IsExist(tableName, columnNames, columnValues);
        }
        public bool IsExist(string sql)
        {
            return dal.IsExist(sql);
        }
        public bool IsExist(string tableName, string where)
        {
            return dal.IsExist(tableName, where);
        }
        /// <summary>
        /// 向数据库添加记录
        /// </summary>
        /// <param name="tableName">表名</param>
        /// <param name="model">表对应的Model,Model里面不需要加到数据库里面的字段，请赋值none</param>
        /// <returns></returns>
        public void Add(string tableName, object model)
        {
            dal.Add(tableName, model);
        }
        public void Add(string tableName, DataTable dt)
        {
            dal.Add(tableName, dt);
        }
        public void Add(string tableName, DataRow dr)
        {
            dal.Add(tableName, dr);
        }
        public void Update(string tableName, DataTable dt, string strWhere)
        {
            dal.Update(tableName, dt, strWhere);
        }
        public void Delete(string tableName, string ColumnName = "", string Value = "")
        {
            dal.Delete(tableName, ColumnName, Value);
        }
        public void Delete(string tableName, string ColumnName, int Value)
        {
            dal.Delete(tableName, ColumnName, Value);
        }
        public void Delete(string tableName, string[] columns, string[] values)
        {
            dal.Delete(tableName, columns, values);
        }
        public void Delete(string sql)
        {
            dal.Delete(sql);
        }
        public void Update(string tableName, string[] filerColumn, string[] filterValue, string[] column, string[] value)
        {
            dal.Update(tableName, filerColumn, filterValue, column, value);
        }
        public void Update(string tableName, object model, string columnName, string value)
        {
            dal.Update(tableName, model, columnName, value);
        }
        public void Update(string tableName, object model, string[] columnNames, string[] values)
        {
            dal.Update(tableName, model, columnNames, values);
        }
        public void Update(string tableName, DataTable dt, string columnName, string value)
        {
            dal.Update(tableName, dt, columnName, value);
        }
        public void Update(string sql)
        {
            dal.Update(sql);
        }
        public void Update(string tableName, DataRow dr, string columnName, string value)
        {
            dal.Update(tableName, dr, columnName, value);
        }
        public void Update(string tableName, DataRow dr, string[] columnName, string[] value)
        {
            dal.Update(tableName, dr, columnName, value);
        }
        public void Update(string tableName, string filterColumn, string filterValue, string columnName, string columnValue)
        {
            dal.Update(tableName, filterColumn, filterValue, columnName, columnValue);
        }
        public void Update(string tableName, DataTable dt, string[] columnNames, string[] values)
        {
            dal.Update(tableName, dt, columnNames, values);
        }

        public void Update(string tableName, object model, string columnName, string value, string Tag)
        {
            dal.Update(tableName, model, columnName, value, Tag);
        }
        public void Update(string tableName, object model, string[] columnNames, string[] values, string Tag)
        {
            dal.Update(tableName, model, columnNames, values, Tag);
        }
        public object SelectFstField(string tableName, string columnName, string filterColumn, string filterValue)
        {
            return dal.SelectFstField(tableName, columnName, filterColumn, filterValue);
        }
        public object SelectFstField(string tableName, string columnName, string filterColumn, int filterValue)
        {
            return dal.SelectFstField(tableName, columnName, filterColumn, filterValue);
        }
        public object SelectFstField(string tableName, string columnName, string strWhere)
        {
            return dal.SelectFstField(tableName, columnName, strWhere);
        }
        public object SelectFstField(string sql)
        {
            return dal.SelectFstField(sql);
        }

        public DataTable Select(string tableName, string strwhere)
        {
            return dal.Select(tableName, strwhere);
        }
        public DataTable Select(string tableName, string filterColumn, string value)
        {
            return dal.Select(tableName, filterColumn, value);
        }
        public DataTable Select(string tableName, string filterColumn, int value)
        {
            return dal.Select(tableName, filterColumn, value);
        }
        public void Select(object model, string tableName, string filterColumn, string value)
        {
            dal.Select(model, tableName, filterColumn, value);
        }
        public DataTable Select(string sql)
        {
            return dal.Select(sql);
        }
        public DataTable Select(string tableName, string filterColumn, string value, string OrderByCol)
        {
            return dal.Select(tableName, filterColumn, value, OrderByCol);
        }
        public void Update(string tableName, object model, string strwhere)
        {
            dal.Update(tableName, model, strwhere);
        }
        public DataTable Select(string tableName, string[] filterColumns, string[] value)
        {
            return dal.Select(tableName, filterColumns, value);
        }
        public DataTable Select(string tableName, string[] filterColumns, string[] value, string OrderByCol)
        {
            return dal.Select(tableName, filterColumns, value, OrderByCol);
        }
        public DataTable Select(string tableName, string[] selectColumns, string[] otherColumns, string filterColumn, string value)
        {
            return dal.Select(tableName, selectColumns, otherColumns, filterColumn, value);
        }
        public DataTable Select(string tableName, string[] selectColumns, string[] otherColumns, string filterColumn, string value, string OrderByCol)
        {
            return dal.Select(tableName, selectColumns, otherColumns, filterColumn, value, OrderByCol);
        }
        public DataTable Select(string tableName, string[] selectColumns, string[] otherColumns, string[] filterColumns, string[] value)
        {
            return dal.Select(tableName, selectColumns, otherColumns, filterColumns, value);
        }
        public DataTable Select(string tableName, string[] selectColumns, string[] otherColumns, string[] filterColumns, string[] value, string OrderByCol)
        {
            return dal.Select(tableName, selectColumns, otherColumns, filterColumns, value, OrderByCol);
        }
        public DataTable MHSelect(string tableName, string filterColumn, string value)
        {
            return dal.MHSelect(tableName, filterColumn, value);
        }
        /// <summary>
        /// 查询表格，并对其进行分页
        /// </summary>
        /// <param name="tableName">表名称</param>
        /// <param name="filterColumn">条件字段名</param>
        /// <param name="value">条件值</param>
        /// <param name="pagingCount">分页显示数量</param>
        /// <param name="pagingIndex">当前页码</param>
        /// <returns></returns>
        public DataTable MHSelectPaging(string tableName, string filterColumn, string value, int pagingCount, int pagingIndex)
        {
            return dal.MHSelectPaging(tableName, filterColumn, value, pagingCount, pagingIndex);
        }
        public DataTable MHSelect(string tableName, string filterColumn, string value, string OrderByCol)
        {
            return dal.MHSelect(tableName, filterColumn, value, OrderByCol);
        }
        public DataTable MHSelect(string tableName, string[] filterColumns, string[] value)
        {
            return dal.MHSelect(tableName, filterColumns, value);
        }
        public DataTable MHSelect(string tableName, string[] filterColumns, string[] value, string OrderByCol)
        {
            return dal.MHSelect(tableName, filterColumns, value, OrderByCol);
        }
        public DataTable MHSelect(string tableName, string[] selectColumns, string[] otherColumns, string filterColumn, string value)
        {
            return dal.MHSelect(tableName, selectColumns, otherColumns, filterColumn, value);
        }
        public DataTable MHSelect(string tableName, string[] selectColumns, string[] otherColumns, string filterColumn, string value, string OrderByCol)
        {
            return dal.MHSelect(tableName, selectColumns, otherColumns, filterColumn, value, OrderByCol);
        }
        public DataTable MHSelect(string tableName, string[] selectColumns, string[] otherColumns, string[] filterColumns, string[] value)
        {
            return dal.MHSelect(tableName, selectColumns, otherColumns, filterColumns, value);
        }
        public DataTable MHSelect(string tableName, string[] selectColumns, string[] otherColumns, string[] filterColumns, string[] value, string OrderByCol)
        {
            return dal.MHSelect(tableName, selectColumns, otherColumns, filterColumns, value, OrderByCol);
        }
        public DataTable FYSelect(string tableName, string[] selectColumns, string[] otherColumns, string[] filterColumns, string[] value, string OrderByCol, int PageSize, int PageIndex)
        {
            return null;//dal.FYSelect(tableName, selectColumns, otherColumns, filterColumns, value, OrderByCol, PageSize, PageIndex);
        }
        public DataTable FYSelect(string tableName, string[] filterColumns, string[] values, string OrderByCol, int PageSize, int PageIndex)
        {
            return dal.FYSelect(tableName, filterColumns, values, OrderByCol, PageSize, PageIndex);
        }
        public DataTable GetTableColumns(string tabName)
        {
            return dal.GetTableColumns(tabName);
        }
        public DataTable GetTableInfo(string tabName)
        {
            return dal.GetTableInfo(tabName);
        }
        /// <summary>
        /// 返回表格指定条件数据集行数
        /// </summary>
        public int GetTableCount(string tabName, string sqlWhere)
        {
            return dal.GetTableCount(tabName, sqlWhere);
        }

        /// <summary>
        /// 根据所给条件获取指定数据
        /// </summary>
        public DataTable GetDataList(string tabName, string sqlWhere)
        {
            return dal.GetDataList(tabName, sqlWhere);
        }
    }
}
